#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int T, n, m, l, vmax, ans, sum, sum1;
int d[N], v[N], a[N], p[N];
bool t = true, t1 = true, flag[N];
int main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> T;
    while(T--) {
        memset(d, 0, sizeof(d));
        memset(v, 0, sizeof(v));
        memset(a, 0, sizeof(a));
        memset(p, 0, sizeof(p));
        t = true, t1 = true;
        ans = 0;
        cin >> n >> m >> l >> vmax;
        for(int i = 1; i <= n; i++) {
            cin >> d[i] >> v[i] >> a[i];
            if(a[i] != 0) t = false;
            if(a[i] <= 0) t1 = false;
        }
        for(int i = 1; i <= m; i++) {
            cin >> p[i];
        }
        if(t) {
            ans = 0;
            int csymax = l - p[m];
            for(int i = 1; i <= n; i++) {
                if(v[i] > vmax && (l - d[i]) >= csymax) {
                    ans++;
                }
            }
            if(ans == 0) {
                cout << ans << " " << m << '\n';
            } else {
                cout << ans << " " << m - 1 << '\n';
            }
        } else if(t1) {
            memset(flag, true, sizeof(flag));
            sum = 0, sum1 = m;
            for(int i = 1; i <= n; i++) {
                if(a[i] == 0 && v[i] > vmax && (l - d[i]) >= (l - p[m])) {
                    sum++;
                    int xb = 0;
                    for(int j = 1; j <= m; j++) {
                        if(!xb && l - d[i] >= l - p[j]) {
                            xb = j;
                        }
                        if(xb != 0) break;
                    }
                    flag[xb] = true;
                    sum1 += (m - 2 * xb);
                }
                int dis = (vmax * vmax - v[i] * v[i]) / 2 * a[i] + d[i];
                if(dis <= l && (l - dis) >= (l - p[m])) {
                    sum++;
                    for(int j = 1; j <= m; j++) {
                        if(dis >= p[j] && flag[j]) {
                            flag[j] = false;
                            sum1++;
                        }
                        if(dis <= p[j] && !flag[j]) {
                            sum--;
                            flag[j] = true;
                        }
                        else break;
                    }
                }
            }
            cout << sum << " " << sum1 << '\n';
        }
    }
    return 0;
}
